// const BASE_URL = `http://zhiyue.free.idcfengye.com`;
const BASE_URL = `https://www.sixkey-world.top:8600`;

export const request = (options) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + options.url,
			method: options.method || 'GET',
			data: options.data || {},
			header: {
				token: uni.getStorageSync('token')
			},
			success: (res) => {
				const data = res.data
				//无权限
				if (data.code === 403) {
					uni.showToast({
						icon: 'error',
						title: data.message
					});
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}
				if (data.code !== 200) {
					uni.showToast({
						icon: 'error',
						title: data.message
					})
				}
				resolve(data)
			},
			fail: (error) => {
				uni.showToast({
					icon: 'error',
					title: '系统繁忙！'
				})
				reject(error)
			}
		})
	})
}